package com.live.adapter;

import java.util.List;
import java.util.Map;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.SimpleAdapter;
import android.widget.TextView;

import com.live.activity.R;
import com.live.tools.LiveTools;

public class LiveMatchSimpleAdapter extends SimpleAdapter {

	private LinearLayout matchStstusView;

	private String locale = LiveTools.getLocaleLanguage();

	public LiveMatchSimpleAdapter(Context context, List<Map<String, Object>> items, int resource, String[] from,
			int[] to) {
		super(context, items, resource, from, to);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = super.getView(position, convertView, parent);
		TextView matchStstus = (TextView) view.findViewById(R.id.matchStatus);
		String matchStstusText = (String) matchStstus.getText();

		matchStstusView = (LinearLayout) view.findViewById(R.id.matchStatusView);
		if (LiveTools.tradToSimp("已结束", locale).equals(matchStstusText)) {
			matchStstusView.setBackgroundColor(Color.parseColor("#DFDFDF"));
		} else if (LiveTools.tradToSimp("未开始", locale).equals(matchStstusText)) {
			matchStstusView.setBackgroundColor(Color.parseColor("#E0F0F8"));
		} else {
			matchStstusView.setBackgroundColor(Color.parseColor("#FFD7D7"));
		}
		return view;
	}
}
